#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include "gipv6.h"
#include <getopt.h>

struct option longopts[] =
{
  { "start", no_argument, NULL, 's'},
  { "stop" , no_argument, NULL, 't'},
  { "kill" , no_argument, NULL, 'k'},
  { "restart", no_argument, NULL, 'r'},
  { "prep", no_argument, NULL, 'p'},
  { "help", no_argument, NULL, 'h'},
  { "stats", no_argument, NULL, 'c'},
  { "confeditorgtk", no_argument, NULL, 'g' },
  { 0, 0, 0, 0 },
};

int main( int argc, char **argv )
{
  char choose;
  uid_t rootuid;
  static const char *shortopts = "stkrphc";

  rootuid = 0;

  setuid( rootuid );

  if( ( choose = getopt_long( argc, argv, shortopts, longopts, NULL)) != -1)
    {
      switch( choose )
        {
        case 's':
          miredo_start();
          hosts_setup();
          stats();
          break;
        case 't':
          miredo_stop();
          hosts_remove();
	  sleep(1);
          stats();
          break;
        case 'k':
          miredo_stop();
          break;
        case 'r':
          miredo_stop();
          miredo_start();
          break;
        case 'p':
          hosts_remove();
          stats();
          break;
        case 'h':
          help();
          break;
        case 'c':
          stats();
          break;
        case 'g':
          confeditor_gtk();
          break;
        default:
          help();
          break;
        }
    }
  else
    {
      help();
    }
  return(0);

}
